import api from "@/api/api.js";
const state = {
	userInfo: null
};

const mutations = {
	SET_USERINFO: (state, userInfo) => {
		state.userInfo = userInfo;
	},
	SET_FAMILY_List: (state, userInfo) => {
		state.familyList = userInfo;
	},
};

const actions = {
	storeSetUserInfo({
		commit,
		state
	}) {
		return new Promise((resolve, reject) => {
			api.fetchUserInfo({
				id: uni.getStorageSync('resident_id')
			}).then((res) => {
				commit('SET_USERINFO', res.data)
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	},
	storeFamilyUserInfo({
		commit,
		state
	}) {
		return new Promise((resolve, reject) => {
			api.documentFamilyList({
				id: uni.getStorageSync('resident_id')
			}).then((res) => {
				
				// commit('SET_FAMILY_List', res.data)
				resolve(res)
			}).catch(err => {
				reject(err)
			})
		})
	}


};
export default {
	namespaced: true,
	state,
	mutations,
	actions
};